import {param2Obj} from '@/utils'


const goodsItem = (i) => {
  return {
    code: 'F1230808asdfasdf',
    name: (i + 1) + '迪奥（Dior） 口红润唇膏 魅惑唇膏001#淡粉色【润唇膏·礼盒包装】 年中钜惠抢先购【低至满第二件半价】点击抢购',
    storeCount: 99,
    price: 300,
    originPrice: 1000,
    saleOut: i % 5 == 0,
    picture: 'https://img14.360buyimg.com/n5/s450x450_jfs/t6022/179/1616614321/227378/25fc090/5934fa55N44f4f6a2.jpg',
    specs: [
      {
        id: '01',
        name: '容量',
        items: [
          {id: '01', name: '50ml', price: 300, storeCount: 99},
          {id: '02', name: '100ml', price: 500, storeCount: 99},
        ]
      },
      {
        id: '02',
        name: '型号',
        items: [
          {id: '01', name: '01', price: 300, storeCount: 99},
          {id: '02', name: '02', price: 500, storeCount: 99},
        ]
      }
    ],
  }
}

export default {
  getGoods: config => {
    const {current, pageSize, category, subCategory, keyword, sortField, sortType} = param2Obj(config.url);
    const pager = {current, pageSize: +pageSize, total: 1000};
    const filter = {category, subCategory, keyword};
    const sort = {sortField, sortType};
    const dataList = [];
    const start = (current - 1) * pageSize;
    const end = Math.min(current * pageSize, pager.total);
    for (let i = start; i < end; i++) {
      dataList.push(goodsItem(i))
    }
    return {pager, filter, sort, dataList};
  },
}
